***BODY OF PAPER GRAPHS

*** SA Treat in Wave 1 vs Wave 2 (all subjects) -- Partisan Self Index
*ALL
clear 
use polbeh_partsocid_dataverse.dta

collapse (mean) meancolselfindex_w1=colselfindex (sd) sdcolselfindex_w1=colselfindex (count) n_w1=colselfindex if wave==1, by(selfandpure)
generate hicolselfindex_w1 = meancolselfindex_w1 + invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n)) 
generate locolselfindex_w1 = meancolselfindex_w1 - invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n))
generate meancolselfindexr_w1=round(meancolselfindex_w1, 0.01)
format meancolselfindexr_w1 %9.2f
save demsw1, replace

clear
use polbeh_partsocid_dataverse.dta
collapse (mean) meancolselfindex_w2=colselfindex (sd) sdcolselfindex_w2=colselfindex (count) n_w2=colselfindex if wave==2, by(selfandpure)
generate hicolselfindex_w2 = meancolselfindex_w2 + invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n)) 
generate locolselfindex_w2 = meancolselfindex_w2 - invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n))
generate meancolselfindexr_w2=round(meancolselfindex_w2, 0.01)
format meancolselfindexr_w2 %9.2f
save demsw2, replace

append using demsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meancolselfindexr_w1 selfandpure) (bar meancolselfindexr_w2 selfandpure) (rcap hicolselfindex_w1 locolselfindex_w1 selfandpure) (rcap hicolselfindex_w2 locolselfindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("All", size(large)) ytitle("Partisan Self Index", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(6(1)10, labsize(4) angle(0))

*DEMOCRATS
clear 
use polbeh_partsocid_dataverse.dta

collapse (mean) meancolselfindex_w1=colselfindex (sd) sdcolselfindex_w1=colselfindex (count) n_w1=colselfindex if wave==1 & democrat==1, by(selfandpure)
generate hicolselfindex_w1 = meancolselfindex_w1 + invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n)) 
generate locolselfindex_w1 = meancolselfindex_w1 - invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n))
generate meancolselfindexr_w1=round(meancolselfindex_w1, 0.01)
format meancolselfindexr_w1 %9.2f
save demsw1, replace

clear
use polbeh_partsocid_dataverse.dta
collapse (mean) meancolselfindex_w2=colselfindex (sd) sdcolselfindex_w2=colselfindex (count) n_w2=colselfindex if wave==2 & democrat==1, by(selfandpure)
generate hicolselfindex_w2 = meancolselfindex_w2 + invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n)) 
generate locolselfindex_w2 = meancolselfindex_w2 - invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n))
generate meancolselfindexr_w2=round(meancolselfindex_w2, 0.01)
format meancolselfindexr_w2 %9.2f
save demsw2, replace

append using demsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meancolselfindexr_w1 selfandpure) (bar meancolselfindexr_w2 selfandpure) (rcap hicolselfindex_w1 locolselfindex_w1 selfandpure) (rcap hicolselfindex_w2 locolselfindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Democrats", size(large)) ytitle("Partisan Self Index", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(6(1)10, labsize(4) angle(0))

*REPUBLICANS
clear 
use polbeh_partsocid_dataverse.dta

collapse (mean) meancolselfindex_w1=colselfindex (sd) sdcolselfindex_w1=colselfindex (count) n_w1=colselfindex if wave==1 & republican==1, by(selfandpure)
generate hicolselfindex_w1 = meancolselfindex_w1 + invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n)) 
generate locolselfindex_w1 = meancolselfindex_w1 - invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n))
generate meancolselfindexr_w1=round(meancolselfindex_w1, 0.01)
format meancolselfindexr_w1 %9.2f
save repsw1, replace

clear
use polbeh_partsocid_dataverse.dta
collapse (mean) meancolselfindex_w2=colselfindex (sd) sdcolselfindex_w2=colselfindex (count) n_w2=colselfindex if wave==2 & republican==1, by(selfandpure)
generate hicolselfindex_w2 = meancolselfindex_w2 + invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n)) 
generate locolselfindex_w2 = meancolselfindex_w2 - invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n))
generate meancolselfindexr_w2=round(meancolselfindex_w2, 0.01)
format meancolselfindexr_w2 %9.2f
save repsw2, replace

append using repsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meancolselfindexr_w1 selfandpure) (bar meancolselfindexr_w2 selfandpure) (rcap hicolselfindex_w1 locolselfindex_w1 selfandpure) (rcap hicolselfindex_w2 locolselfindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Republicans", size(large)) ytitle("Partisan Self Index", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(6(1)10, labsize(4) angle(0))


*** SA Treat in Wave 1 vs Wave 2 (all subjects) -- Therms
*ALL
clear 
use polbeh_partsocid_dataverse.dta

collapse (mean) meaninoutpartytherm_w1=inoutpartytherm (sd) sdinoutpartytherm_w1=inoutpartytherm (count) n_w1=inoutpartytherm if wave==1, by(selfandpure)
generate hiinoutpartytherm_w1 = meaninoutpartytherm_w1 + invttail(n-1,0.050)*(sdinoutpartytherm_w1 / sqrt(n)) 
generate loinoutpartytherm_w1 = meaninoutpartytherm_w1 - invttail(n-1,0.050)*(sdinoutpartytherm_w1 / sqrt(n))
generate meaninoutpartythermr_w1=round(meaninoutpartytherm_w1, 0.01)
format meaninoutpartythermr_w1 %9.2f
save allw1, replace

clear
use polbeh_partsocid_dataverse.dta
collapse (mean) meaninoutpartytherm_w2=inoutpartytherm (sd) sdinoutpartytherm_w2=inoutpartytherm (count) n_w2=inoutpartytherm if wave==2, by(selfandpure)
generate hiinoutpartytherm_w2 = meaninoutpartytherm_w2 + invttail(n-1,0.050)*(sdinoutpartytherm_w2 / sqrt(n)) 
generate loinoutpartytherm_w2 = meaninoutpartytherm_w2 - invttail(n-1,0.050)*(sdinoutpartytherm_w2 / sqrt(n))
generate meaninoutpartythermr_w2=round(meaninoutpartytherm_w2, 0.01)
format meaninoutpartythermr_w2 %9.2f
save allw2, replace

append using allw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meaninoutpartythermr_w1 selfandpure) (bar meaninoutpartythermr_w2 selfandpure) (rcap hiinoutpartytherm_w1 loinoutpartytherm_w1 selfandpure) (rcap hiinoutpartytherm_w2 loinoutpartytherm_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("All", size(large)) ytitle("In-Out Party Therms", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(45(5)65, labsize(4) angle(0))


*DEMOCRATS
clear 
use polbeh_partsocid_dataverse.dta

collapse (mean) meaninoutpartytherm_dems_w1=inoutpartytherm (sd) sdinoutpartytherm_dems_w1=inoutpartytherm (count) n_w1=inoutpartytherm if wave==1 & democrat==1, by(selfandpure)
generate hiinoutpartytherm_dems_w1 = meaninoutpartytherm_dems_w1 + invttail(n-1,0.050)*(sdinoutpartytherm_dems_w1 / sqrt(n)) 
generate loinoutpartytherm_dems_w1 = meaninoutpartytherm_dems_w1 - invttail(n-1,0.050)*(sdinoutpartytherm_dems_w1 / sqrt(n))
generate meaninoutpartytherm_demsr_w1=round(meaninoutpartytherm_dems_w1, 0.01)
format meaninoutpartytherm_demsr_w1 %9.2f
save demsw1, replace

clear
use polbeh_partsocid_dataverse.dta
collapse (mean) meaninoutpartytherm_dems_w2=inoutpartytherm (sd) sdinoutpartytherm_dems_w2=inoutpartytherm (count) n_w2=inoutpartytherm if wave==2 & democrat==1, by(selfandpure)
generate hiinoutpartytherm_dems_w2 = meaninoutpartytherm_dems_w2 + invttail(n-1,0.050)*(sdinoutpartytherm_dems_w2 / sqrt(n)) 
generate loinoutpartytherm_dems_w2 = meaninoutpartytherm_dems_w2 - invttail(n-1,0.050)*(sdinoutpartytherm_dems_w2 / sqrt(n))
generate meaninoutpartytherm_demsr_w2=round(meaninoutpartytherm_dems_w2, 0.01)
format meaninoutpartytherm_demsr_w2 %9.2f
save demsw2, replace

append using demsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meaninoutpartytherm_demsr_w1 selfandpure) (bar meaninoutpartytherm_demsr_w2 selfandpure) (rcap hiinoutpartytherm_dems_w1 loinoutpartytherm_dems_w1 selfandpure) (rcap hiinoutpartytherm_dems_w2 loinoutpartytherm_dems_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Democrats", size(large)) ytitle("In-Out Party Therms", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(45(5)65, labsize(4) angle(0))


*REPUBLICANS
clear 
use polbeh_partsocid_dataverse.dta

collapse (mean) meaninoutpartytherm_reps_w1=inoutpartytherm (sd) sdinoutpartytherm_reps_w1=inoutpartytherm (count) n_w1=inoutpartytherm if wave==1 & republican==1, by(selfandpure)
generate hiinoutpartytherm_reps_w1 = meaninoutpartytherm_reps_w1 + invttail(n-1,0.050)*(sdinoutpartytherm_reps_w1 / sqrt(n)) 
generate loinoutpartytherm_reps_w1 = meaninoutpartytherm_reps_w1 - invttail(n-1,0.050)*(sdinoutpartytherm_reps_w1 / sqrt(n))
generate meaninoutpartytherm_repsr_w1=round(meaninoutpartytherm_reps_w1, 0.01)
format meaninoutpartytherm_repsr_w1 %9.2f
save repsw1, replace

clear
use polbeh_partsocid_dataverse.dta
collapse (mean) meaninoutpartytherm_reps_w2=inoutpartytherm (sd) sdinoutpartytherm_reps_w2=inoutpartytherm (count) n_w2=inoutpartytherm if wave==2 & republican==1, by(selfandpure)
generate hiinoutpartytherm_reps_w2 = meaninoutpartytherm_reps_w2 + invttail(n-1,0.050)*(sdinoutpartytherm_reps_w2 / sqrt(n)) 
generate loinoutpartytherm_reps_w2 = meaninoutpartytherm_reps_w2 - invttail(n-1,0.050)*(sdinoutpartytherm_reps_w2 / sqrt(n))
generate meaninoutpartytherm_repsr_w2=round(meaninoutpartytherm_reps_w2, 0.01)
format meaninoutpartytherm_repsr_w2 %9.2f
save repsw2, replace

append using repsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meaninoutpartytherm_repsr_w1 selfandpure) (bar meaninoutpartytherm_repsr_w2 selfandpure) (rcap hiinoutpartytherm_reps_w1 loinoutpartytherm_reps_w1 selfandpure) (rcap hiinoutpartytherm_reps_w2 loinoutpartytherm_reps_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Republicans", size(large)) ytitle("In-Out Party Therms.", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(45(5)65, labsize(4) angle(0))



*** SA Treat in Wave 1 vs Wave 2 (all subjects) -- Traits
*ALL

clear
use polbeh_partsocid_dataverse.dta

collapse (mean) minoutpartytraitsindex_w1=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_w1=inoutpartytraitsindex (count) n_w1=inoutpartytraitsindex if wave==1, by(selfandpure)
generate hiinoutpartytraitsindex_w1 = minoutpartytraitsindex_w1 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_w1 / sqrt(n)) 
generate loinoutpartytraitsindex_w1 = minoutpartytraitsindex_w1 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_w1 / sqrt(n))
generate minoutpartytraitsindexr_w1=round(minoutpartytraitsindex_w1, 0.01)
format minoutpartytraitsindexr_w1 %9.2f
save allw1, replace

clear
use polbeh_partsocid_dataverse.dta

collapse (mean) minoutpartytraitsindex_w2=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_w2=inoutpartytraitsindex (count) n_w2=inoutpartytraitsindex if wave==2, by(selfandpure)
generate hiinoutpartytraitsindex_w2 = minoutpartytraitsindex_w2 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_w2 / sqrt(n)) 
generate loinoutpartytraitsindex_w2 = minoutpartytraitsindex_w2 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_w2 / sqrt(n))
generate minoutpartytraitsindexr_w2=round(minoutpartytraitsindex_w2, 0.01)
format minoutpartytraitsindexr_w2 %9.2f
save allw2, replace


append using allw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar minoutpartytraitsindexr_w1 selfandpure) (bar minoutpartytraitsindexr_w2 selfandpure) (rcap hiinoutpartytraitsindex_w1 loinoutpartytraitsindex_w1 selfandpure) (rcap hiinoutpartytraitsindex_w2 loinoutpartytraitsindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("All", size(large)) ytitle("In-Out Party Supp. Traits", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(3(.2)5.5, labsize(4) angle(0))


*DEMOCRATS

clear
use polbeh_partsocid_dataverse.dta

collapse (mean) minoutpartytraitsindex_w1=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_w1=inoutpartytraitsindex (count) n_w1=inoutpartytraitsindex if wave==1 & democrat==1, by(selfandpure)
generate hiinoutpartytraitsindex_w1 = minoutpartytraitsindex_w1 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_w1 / sqrt(n)) 
generate loinoutpartytraitsindex_w1 = minoutpartytraitsindex_w1 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_w1 / sqrt(n))
generate minoutpartytraitsindexr_w1=round(minoutpartytraitsindex_w1, 0.01)
format minoutpartytraitsindexr_w1 %9.2f
save demsw1, replace

clear
use polbeh_partsocid_dataverse.dta

collapse (mean) minoutpartytraitsindex_w2=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_w2=inoutpartytraitsindex (count) n_w2=inoutpartytraitsindex if wave==2 & democrat==1, by(selfandpure)
generate hiinoutpartytraitsindex_w2 = minoutpartytraitsindex_w2 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_w2 / sqrt(n)) 
generate loinoutpartytraitsindex_w2 = minoutpartytraitsindex_w2 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_w2 / sqrt(n))
generate minoutpartytraitsindexr_w2=round(minoutpartytraitsindex_w2, 0.01)
format minoutpartytraitsindexr_w2 %9.2f
save demsw2, replace


append using demsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar minoutpartytraitsindexr_w1 selfandpure) (bar minoutpartytraitsindexr_w2 selfandpure) (rcap hiinoutpartytraitsindex_w1 loinoutpartytraitsindex_w1 selfandpure) (rcap hiinoutpartytraitsindex_w2 loinoutpartytraitsindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Democrats", size(large)) ytitle("In-Out Party Supp. Traits", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(3(.2)5.5, labsize(4) angle(0))


*REPUBLICANS
clear
use polbeh_partsocid_dataverse.dta

collapse (mean) minoutpartytraitsindex_w1=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_w1=inoutpartytraitsindex (count) n_w1=inoutpartytraitsindex if wave==1 & republican==1, by(selfandpure)
generate hiinoutpartytraitsindex_w1 = minoutpartytraitsindex_w1 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_w1 / sqrt(n)) 
generate loinoutpartytraitsindex_w1 = minoutpartytraitsindex_w1 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_w1 / sqrt(n))
generate minoutpartytraitsindexr_w1=round(minoutpartytraitsindex_w1, 0.01)
format minoutpartytraitsindexr_w1 %9.2f
save repsw1, replace

clear
use polbeh_partsocid_dataverse.dta

collapse (mean) minoutpartytraitsindex_w2=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_w2=inoutpartytraitsindex (count) n_w2=inoutpartytraitsindex if wave==2 & republican==1, by(selfandpure)
generate hiinoutpartytraitsindex_w2 = minoutpartytraitsindex_w2 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_w2 / sqrt(n)) 
generate loinoutpartytraitsindex_w2 = minoutpartytraitsindex_w2 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_w2 / sqrt(n))
generate minoutpartytraitsindexr_w2=round(minoutpartytraitsindex_w2, 0.01)
format minoutpartytraitsindexr_w2 %9.2f
save repsw2, replace

append using repsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar minoutpartytraitsindexr_w1 selfandpure) (bar minoutpartytraitsindexr_w2 selfandpure) (rcap hiinoutpartytraitsindex_w1 loinoutpartytraitsindex_w1 selfandpure) (rcap hiinoutpartytraitsindex_w2 loinoutpartytraitsindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Republicans", size(large)) ytitle("In-Out Party Supp. Traits", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(3(.2)5.5, labsize(4) angle(0))






*********************************************************************************************************
*********************************************************************************************************
*********************************************************************************************************
***APPENDIX -- DESCRIPTIVE STATS -- DISTRIBUTIONS OF OUTCOME VARIABLES BY WAVE
*********************************************************************************************************
*********************************************************************************************************
*********************************************************************************************************

**PARTISAN SELF INDEX
hist colselfindex if wave==1, xscale(range(0 12)) legend(off) xtitle("Partisan Self Index, Wave 1", size(Huge)) ytitle("Density", size(Huge)) graphregion(color(white)) bgcolor(white) scheme(s2mono) 
hist colselfindex if wave==2, xscale(range(0 12)) legend(off) xtitle("Partisan Self Index, Wave 2", size(Huge)) ytitle("Density", size(Huge)) graphregion(color(white)) bgcolor(white) scheme(s2mono) 

**IN-OUT PARTY THERMS
hist inoutpartytherm if wave==1, xscale(range(0 12)) legend(off) xtitle("In-Out Party Therms, Wave 1", size(Huge)) ytitle("Density", size(Huge)) graphregion(color(white)) bgcolor(white) scheme(s2mono) 
hist inoutpartytherm if wave==2, xscale(range(0 12)) legend(off) xtitle("In-Out Party Therms, Wave 2", size(Huge)) ytitle("Density", size(Huge)) graphregion(color(white)) bgcolor(white) scheme(s2mono) 

**IN-OUT PARTY TRAITS
hist inoutpartytraitsindex if wave==1, xscale(range(0 12)) legend(off) xtitle("In-Out Party Therms, Wave 1", size(Huge)) ytitle("Density", size(Huge)) graphregion(color(white)) bgcolor(white) scheme(s2mono) 
hist inoutpartytraitsindex if wave==2, xscale(range(0 12)) legend(off) xtitle("In-Out Party Therms, Wave 2", size(Huge)) ytitle("Density", size(Huge)) graphregion(color(white)) bgcolor(white) scheme(s2mono) 


*********************************************************************************************************
*********************************************************************************************************
*********************************************************************************************************
***APPENDIX REPLICATIONS WITH TRUE PANEL SUBJECTS ONLY
*********************************************************************************************************
*********************************************************************************************************
*********************************************************************************************************


*** SA Treat in Wave 1 vs Wave 2 (true panel subjects only) -- Partisan Self Index
*ALL
clear 
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) meancolselfindex_w1=colselfindex (sd) sdcolselfindex_w1=colselfindex (count) n_w1=colselfindex if wave==1, by(selfandpure)
generate hicolselfindex_w1 = meancolselfindex_w1 + invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n)) 
generate locolselfindex_w1 = meancolselfindex_w1 - invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n))
generate meancolselfindexr_w1=round(meancolselfindex_w1, 0.01)
format meancolselfindexr_w1 %9.2f
save demsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if panel==0
collapse (mean) meancolselfindex_w2=colselfindex (sd) sdcolselfindex_w2=colselfindex (count) n_w2=colselfindex if wave==2, by(selfandpure)
generate hicolselfindex_w2 = meancolselfindex_w2 + invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n)) 
generate locolselfindex_w2 = meancolselfindex_w2 - invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n))
generate meancolselfindexr_w2=round(meancolselfindex_w2, 0.01)
format meancolselfindexr_w2 %9.2f
save demsw2, replace

append using demsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meancolselfindexr_w1 selfandpure) (bar meancolselfindexr_w2 selfandpure) (rcap hicolselfindex_w1 locolselfindex_w1 selfandpure) (rcap hicolselfindex_w2 locolselfindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("All", size(large)) ytitle("Partisan Self Index", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(6(1)10, labsize(4) angle(0))


*DEMOCRATS
clear 
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) meancolselfindex_w1=colselfindex (sd) sdcolselfindex_w1=colselfindex (count) n_w1=colselfindex if wave==1 & democrat==1, by(selfandpure)
generate hicolselfindex_w1 = meancolselfindex_w1 + invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n)) 
generate locolselfindex_w1 = meancolselfindex_w1 - invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n))
generate meancolselfindexr_w1=round(meancolselfindex_w1, 0.01)
format meancolselfindexr_w1 %9.2f
save demsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if panel==0
collapse (mean) meancolselfindex_w2=colselfindex (sd) sdcolselfindex_w2=colselfindex (count) n_w2=colselfindex if wave==2 & democrat==1, by(selfandpure)
generate hicolselfindex_w2 = meancolselfindex_w2 + invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n)) 
generate locolselfindex_w2 = meancolselfindex_w2 - invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n))
generate meancolselfindexr_w2=round(meancolselfindex_w2, 0.01)
format meancolselfindexr_w2 %9.2f
save demsw2, replace

append using demsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meancolselfindexr_w1 selfandpure) (bar meancolselfindexr_w2 selfandpure) (rcap hicolselfindex_w1 locolselfindex_w1 selfandpure) (rcap hicolselfindex_w2 locolselfindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Democrats", size(large)) ytitle("Partisan Self Index", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(6(1)10, labsize(4) angle(0))


*REPUBLICANS
clear 
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) meancolselfindex_w1=colselfindex (sd) sdcolselfindex_w1=colselfindex (count) n_w1=colselfindex if wave==1 & republican==1, by(selfandpure)
generate hicolselfindex_w1 = meancolselfindex_w1 + invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n)) 
generate locolselfindex_w1 = meancolselfindex_w1 - invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n))
generate meancolselfindexr_w1=round(meancolselfindex_w1, 0.01)
format meancolselfindexr_w1 %9.2f
save repsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if panel==0
collapse (mean) meancolselfindex_w2=colselfindex (sd) sdcolselfindex_w2=colselfindex (count) n_w2=colselfindex if wave==2 & republican==1, by(selfandpure)
generate hicolselfindex_w2 = meancolselfindex_w2 + invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n)) 
generate locolselfindex_w2 = meancolselfindex_w2 - invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n))
generate meancolselfindexr_w2=round(meancolselfindex_w2, 0.01)
format meancolselfindexr_w2 %9.2f
save repsw2, replace

append using repsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meancolselfindexr_w1 selfandpure) (bar meancolselfindexr_w2 selfandpure) (rcap hicolselfindex_w1 locolselfindex_w1 selfandpure) (rcap hicolselfindex_w2 locolselfindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Republicans", size(large)) ytitle("Partisan Self Index", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(6(1)10, labsize(4) angle(0))




*** SA Treat in Wave 1 vs Wave 2 (all subjects) -- Therms
*ALL
clear 
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) meaninoutpartytherm_w1=inoutpartytherm (sd) sdinoutpartytherm_w1=inoutpartytherm (count) n_w1=inoutpartytherm if wave==1, by(selfandpure)
generate hiinoutpartytherm_w1 = meaninoutpartytherm_w1 + invttail(n-1,0.050)*(sdinoutpartytherm_w1 / sqrt(n)) 
generate loinoutpartytherm_w1 = meaninoutpartytherm_w1 - invttail(n-1,0.050)*(sdinoutpartytherm_w1 / sqrt(n))
generate meaninoutpartythermr_w1=round(meaninoutpartytherm_w1, 0.01)
format meaninoutpartythermr_w1 %9.2f
save allw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if panel==0
collapse (mean) meaninoutpartytherm_w2=inoutpartytherm (sd) sdinoutpartytherm_w2=inoutpartytherm (count) n_w2=inoutpartytherm if wave==2, by(selfandpure)
generate hiinoutpartytherm_w2 = meaninoutpartytherm_w2 + invttail(n-1,0.050)*(sdinoutpartytherm_w2 / sqrt(n)) 
generate loinoutpartytherm_w2 = meaninoutpartytherm_w2 - invttail(n-1,0.050)*(sdinoutpartytherm_w2 / sqrt(n))
generate meaninoutpartythermr_w2=round(meaninoutpartytherm_w2, 0.01)
format meaninoutpartythermr_w2 %9.2f
save allw2, replace

append using allw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meaninoutpartythermr_w1 selfandpure) (bar meaninoutpartythermr_w2 selfandpure) (rcap hiinoutpartytherm_w1 loinoutpartytherm_w1 selfandpure) (rcap hiinoutpartytherm_w2 loinoutpartytherm_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("All", size(large)) ytitle("In-Out Party Therms", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(45(5)65, labsize(4) angle(0))


*DEMOCRATS
clear 
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) meaninoutpartytherm_dems_w1=inoutpartytherm (sd) sdinoutpartytherm_dems_w1=inoutpartytherm (count) n_w1=inoutpartytherm if wave==1 & democrat==1, by(selfandpure)
generate hiinoutpartytherm_dems_w1 = meaninoutpartytherm_dems_w1 + invttail(n-1,0.050)*(sdinoutpartytherm_dems_w1 / sqrt(n)) 
generate loinoutpartytherm_dems_w1 = meaninoutpartytherm_dems_w1 - invttail(n-1,0.050)*(sdinoutpartytherm_dems_w1 / sqrt(n))
generate meaninoutpartytherm_demsr_w1=round(meaninoutpartytherm_dems_w1, 0.01)
format meaninoutpartytherm_demsr_w1 %9.2f
save demsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if panel==0
collapse (mean) meaninoutpartytherm_dems_w2=inoutpartytherm (sd) sdinoutpartytherm_dems_w2=inoutpartytherm (count) n_w2=inoutpartytherm if wave==2 & democrat==1, by(selfandpure)
generate hiinoutpartytherm_dems_w2 = meaninoutpartytherm_dems_w2 + invttail(n-1,0.050)*(sdinoutpartytherm_dems_w2 / sqrt(n)) 
generate loinoutpartytherm_dems_w2 = meaninoutpartytherm_dems_w2 - invttail(n-1,0.050)*(sdinoutpartytherm_dems_w2 / sqrt(n))
generate meaninoutpartytherm_demsr_w2=round(meaninoutpartytherm_dems_w2, 0.01)
format meaninoutpartytherm_demsr_w2 %9.2f
save demsw2, replace

append using demsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meaninoutpartytherm_demsr_w1 selfandpure) (bar meaninoutpartytherm_demsr_w2 selfandpure) (rcap hiinoutpartytherm_dems_w1 loinoutpartytherm_dems_w1 selfandpure) (rcap hiinoutpartytherm_dems_w2 loinoutpartytherm_dems_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Democrats", size(large)) ytitle("In-Out Party Therms", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(45(5)65, labsize(4) angle(0))


*REPUBLICANS
clear 
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) meaninoutpartytherm_reps_w1=inoutpartytherm (sd) sdinoutpartytherm_reps_w1=inoutpartytherm (count) n_w1=inoutpartytherm if wave==1 & republican==1, by(selfandpure)
generate hiinoutpartytherm_reps_w1 = meaninoutpartytherm_reps_w1 + invttail(n-1,0.050)*(sdinoutpartytherm_reps_w1 / sqrt(n)) 
generate loinoutpartytherm_reps_w1 = meaninoutpartytherm_reps_w1 - invttail(n-1,0.050)*(sdinoutpartytherm_reps_w1 / sqrt(n))
generate meaninoutpartytherm_repsr_w1=round(meaninoutpartytherm_reps_w1, 0.01)
format meaninoutpartytherm_repsr_w1 %9.2f
save repsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) meaninoutpartytherm_reps_w2=inoutpartytherm (sd) sdinoutpartytherm_reps_w2=inoutpartytherm (count) n_w2=inoutpartytherm if wave==2 & republican==1, by(selfandpure)
generate hiinoutpartytherm_reps_w2 = meaninoutpartytherm_reps_w2 + invttail(n-1,0.050)*(sdinoutpartytherm_reps_w2 / sqrt(n)) 
generate loinoutpartytherm_reps_w2 = meaninoutpartytherm_reps_w2 - invttail(n-1,0.050)*(sdinoutpartytherm_reps_w2 / sqrt(n))
generate meaninoutpartytherm_repsr_w2=round(meaninoutpartytherm_reps_w2, 0.01)
format meaninoutpartytherm_repsr_w2 %9.2f
save repsw2, replace

append using repsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meaninoutpartytherm_repsr_w1 selfandpure) (bar meaninoutpartytherm_repsr_w2 selfandpure) (rcap hiinoutpartytherm_reps_w1 loinoutpartytherm_reps_w1 selfandpure) (rcap hiinoutpartytherm_reps_w2 loinoutpartytherm_reps_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Republicans", size(large)) ytitle("In-Out Party Therms.", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(45(5)65, labsize(4) angle(0))


*** SA Treat in Wave 1 vs Wave 2 (all subjects) -- Traits
*All

clear
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) minoutpartytraitsindex_w1=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_w1=inoutpartytraitsindex (count) n_w1=inoutpartytraitsindex if wave==1 , by(selfandpure)
generate hiinoutpartytraitsindex_w1 = minoutpartytraitsindex_w1 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_w1 / sqrt(n)) 
generate loinoutpartytraitsindex_w1 = minoutpartytraitsindex_w1 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_w1 / sqrt(n))
generate minoutpartytraitsindexr_w1=round(minoutpartytraitsindex_w1, 0.01)
format minoutpartytraitsindexr_w1 %9.2f
save allw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) minoutpartytraitsindex_w2=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_w2=inoutpartytraitsindex (count) n_w2=inoutpartytraitsindex if wave==2 , by(selfandpure)
generate hiinoutpartytraitsindex_w2 = minoutpartytraitsindex_w2 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_w2 / sqrt(n)) 
generate loinoutpartytraitsindex_w2 = minoutpartytraitsindex_w2 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_w2 / sqrt(n))
generate minoutpartytraitsindexr_w2=round(minoutpartytraitsindex_w2, 0.01)
format minoutpartytraitsindexr_w2 %9.2f
save allw2, replace


append using allw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar minoutpartytraitsindexr_w1 selfandpure) (bar minoutpartytraitsindexr_w2 selfandpure) (rcap hiinoutpartytraitsindex_w1 loinoutpartytraitsindex_w1 selfandpure) (rcap hiinoutpartytraitsindex_w2 loinoutpartytraitsindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("All", size(large)) ytitle("In-Out Party Supp. Traits", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(3(.2)5.5, labsize(4) angle(0))


*DEMOCRATS

clear
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) minoutpartytraitsindex_dems_w1=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_dems_w1=inoutpartytraitsindex (count) n_w1=inoutpartytraitsindex if wave==1 & democrat==1, by(selfandpure)
generate hiinoutpartytraitsindex_dems_w1 = minoutpartytraitsindex_dems_w1 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_dems_w1 / sqrt(n)) 
generate loinoutpartytraitsindex_dems_w1 = minoutpartytraitsindex_dems_w1 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_dems_w1 / sqrt(n))
generate minoutpartytraitsindex_demsr_w1=round(minoutpartytraitsindex_dems_w1, 0.01)
format minoutpartytraitsindex_demsr_w1 %9.2f
save demsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) minoutpartytraitsindex_dems_w2=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_dems_w2=inoutpartytraitsindex (count) n_w2=inoutpartytraitsindex if wave==2 & democrat==1, by(selfandpure)
generate hiinoutpartytraitsindex_dems_w2 = minoutpartytraitsindex_dems_w2 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_dems_w2 / sqrt(n)) 
generate loinoutpartytraitsindex_dems_w2 = minoutpartytraitsindex_dems_w2 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_dems_w2 / sqrt(n))
generate minoutpartytraitsindex_demsr_w2=round(minoutpartytraitsindex_dems_w2, 0.01)
format minoutpartytraitsindex_demsr_w2 %9.2f
save demsw2, replace


append using demsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar minoutpartytraitsindex_demsr_w1 selfandpure) (bar minoutpartytraitsindex_demsr_w2 selfandpure) (rcap hiinoutpartytraitsindex_dems_w1 loinoutpartytraitsindex_dems_w1 selfandpure) (rcap hiinoutpartytraitsindex_dems_w2 loinoutpartytraitsindex_dems_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Democrats", size(large)) ytitle("In-Out Party Supp. Traits", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(3(.2)5.5, labsize(4) angle(0))


*REPUBLICANS
clear
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) minoutpartytraitsindex_reps_w1=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_reps_w1=inoutpartytraitsindex (count) n_w1=inoutpartytraitsindex if wave==1 & republican==1, by(selfandpure)
generate hiinoutpartytraitsindex_reps_w1 = minoutpartytraitsindex_reps_w1 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_reps_w1 / sqrt(n)) 
generate loinoutpartytraitsindex_reps_w1 = minoutpartytraitsindex_reps_w1 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_reps_w1 / sqrt(n))
generate minoutpartytraitsindex_repsr_w1=round(minoutpartytraitsindex_reps_w1, 0.01)
format minoutpartytraitsindex_repsr_w1 %9.2f
save repsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if panel==0

collapse (mean) minoutpartytraitsindex_reps_w2=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_reps_w2=inoutpartytraitsindex (count) n_w2=inoutpartytraitsindex if wave==2 & republican==1, by(selfandpure)
generate hiinoutpartytraitsindex_reps_w2 = minoutpartytraitsindex_reps_w2 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_reps_w2 / sqrt(n)) 
generate loinoutpartytraitsindex_reps_w2 = minoutpartytraitsindex_reps_w2 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_reps_w2 / sqrt(n))
generate minoutpartytraitsindex_repsr_w2=round(minoutpartytraitsindex_reps_w2, 0.01)
format minoutpartytraitsindex_repsr_w2 %9.2f
save repsw2, replace

append using repsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar minoutpartytraitsindex_repsr_w1 selfandpure) (bar minoutpartytraitsindex_repsr_w2 selfandpure) (rcap hiinoutpartytraitsindex_reps_w1 loinoutpartytraitsindex_reps_w1 selfandpure) (rcap hiinoutpartytraitsindex_reps_w2 loinoutpartytraitsindex_reps_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Republicans", size(large)) ytitle("In-Out Party Supp. Traits", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(3(.2)5.5, labsize(4) angle(0))



*********************************************************************************************************
*********************************************************************************************************
*********************************************************************************************************
***APPENDIX -- CHECK TO MAKE SURE STILL NO SA EFFECT IN WAVE 2 
*EVEN IF EXCLUDE THOSE WHO GOT SA TREAT IN W1 (not just "testing effects")
*********************************************************************************************************
*********************************************************************************************************
*********************************************************************************************************


*** SA Treat in Wave 1 vs Wave 2 (true panel subjects only) NO W1 Treated -- Partisan Self Index
*ALL
clear 
use polbeh_partsocid_dataverse.dta

collapse (mean) meancolselfindex_w1=colselfindex (sd) sdcolselfindex_w1=colselfindex (count) n_w1=colselfindex if wave==1 , by(selfandpure)
generate hicolselfindex_w1 = meancolselfindex_w1 + invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n)) 
generate locolselfindex_w1 = meancolselfindex_w1 - invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n))
generate meancolselfindexr_w1=round(meancolselfindex_w1, 0.01)
format meancolselfindexr_w1 %9.2f
save allw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if treatw1==1

collapse (mean) meancolselfindex_w2=colselfindex (sd) sdcolselfindex_w2=colselfindex (count) n_w2=colselfindex if wave==2 , by(selfandpure)
generate hicolselfindex_w2 = meancolselfindex_w2 + invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n)) 
generate locolselfindex_w2 = meancolselfindex_w2 - invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n))
generate meancolselfindexr_w2=round(meancolselfindex_w2, 0.01)
format meancolselfindexr_w2 %9.2f
save allw2, replace

append using allw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meancolselfindexr_w1 selfandpure) (bar meancolselfindexr_w2 selfandpure) (rcap hicolselfindex_w1 locolselfindex_w1 selfandpure) (rcap hicolselfindex_w2 locolselfindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("All", size(large)) ytitle("Partisan Self Index", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(6(1)10, labsize(4) angle(0))

*DEMOCRATS
clear 
use polbeh_partsocid_dataverse.dta

collapse (mean) meancolselfindex_w1=colselfindex (sd) sdcolselfindex_w1=colselfindex (count) n_w1=colselfindex if wave==1 & democrat==1, by(selfandpure)
generate hicolselfindex_w1 = meancolselfindex_w1 + invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n)) 
generate locolselfindex_w1 = meancolselfindex_w1 - invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n))
generate meancolselfindexr_w1=round(meancolselfindex_w1, 0.01)
format meancolselfindexr_w1 %9.2f
save demsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if treatw1==1

collapse (mean) meancolselfindex_w2=colselfindex (sd) sdcolselfindex_w2=colselfindex (count) n_w2=colselfindex if wave==2 & democrat==1, by(selfandpure)
generate hicolselfindex_w2 = meancolselfindex_w2 + invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n)) 
generate locolselfindex_w2 = meancolselfindex_w2 - invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n))
generate meancolselfindexr_w2=round(meancolselfindex_w2, 0.01)
format meancolselfindexr_w2 %9.2f
save demsw2, replace

append using demsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meancolselfindexr_w1 selfandpure) (bar meancolselfindexr_w2 selfandpure) (rcap hicolselfindex_w1 locolselfindex_w1 selfandpure) (rcap hicolselfindex_w2 locolselfindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Democrats", size(large)) ytitle("Partisan Self Index", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(6(1)10, labsize(4) angle(0))


*REPUBLICANS
clear 
use polbeh_partsocid_dataverse.dta


collapse (mean) meancolselfindex_w1=colselfindex (sd) sdcolselfindex_w1=colselfindex (count) n_w1=colselfindex if wave==1 & republican==1, by(selfandpure)
generate hicolselfindex_w1 = meancolselfindex_w1 + invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n)) 
generate locolselfindex_w1 = meancolselfindex_w1 - invttail(n-1,0.050)*(sdcolselfindex_w1 / sqrt(n))
generate meancolselfindexr_w1=round(meancolselfindex_w1, 0.01)
format meancolselfindexr_w1 %9.2f
save repsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if treatw1==1

collapse (mean) meancolselfindex_w2=colselfindex (sd) sdcolselfindex_w2=colselfindex (count) n_w2=colselfindex if wave==2 & republican==1, by(selfandpure)
generate hicolselfindex_w2 = meancolselfindex_w2 + invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n)) 
generate locolselfindex_w2 = meancolselfindex_w2 - invttail(n-1,0.050)*(sdcolselfindex_w2 / sqrt(n))
generate meancolselfindexr_w2=round(meancolselfindex_w2, 0.01)
format meancolselfindexr_w2 %9.2f
save repsw2, replace

append using repsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meancolselfindexr_w1 selfandpure) (bar meancolselfindexr_w2 selfandpure) (rcap hicolselfindex_w1 locolselfindex_w1 selfandpure) (rcap hicolselfindex_w2 locolselfindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Republicans", size(large)) ytitle("Partisan Self Index", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(6(1)10, labsize(4) angle(0))




*** SA Treat in Wave 1 vs Wave 2 (all subjects) -- Therms
*ALL
clear 
use polbeh_partsocid_dataverse.dta

collapse (mean) meaninoutpartytherm_w1=inoutpartytherm (sd) sdinoutpartytherm_w1=inoutpartytherm (count) n_w1=inoutpartytherm if wave==1 , by(selfandpure)
generate hiinoutpartytherm_w1 = meaninoutpartytherm_w1 + invttail(n-1,0.050)*(sdinoutpartytherm_w1 / sqrt(n)) 
generate loinoutpartytherm_w1 = meaninoutpartytherm_w1 - invttail(n-1,0.050)*(sdinoutpartytherm_w1 / sqrt(n))
generate meaninoutpartythermr_w1=round(meaninoutpartytherm_w1, 0.01)
format meaninoutpartythermr_w1 %9.2f
save allw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if treatw1==1

collapse (mean) meaninoutpartytherm_w2=inoutpartytherm (sd) sdinoutpartytherm_w2=inoutpartytherm (count) n_w2=inoutpartytherm if wave==2 , by(selfandpure)
generate hiinoutpartytherm_w2 = meaninoutpartytherm_w2 + invttail(n-1,0.050)*(sdinoutpartytherm_w2 / sqrt(n)) 
generate loinoutpartytherm_w2 = meaninoutpartytherm_w2 - invttail(n-1,0.050)*(sdinoutpartytherm_w2 / sqrt(n))
generate meaninoutpartythermr_w2=round(meaninoutpartytherm_w2, 0.01)
format meaninoutpartythermr_w2 %9.2f
save allw2, replace

append using allw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meaninoutpartythermr_w1 selfandpure) (bar meaninoutpartythermr_w2 selfandpure) (rcap hiinoutpartytherm_w1 loinoutpartytherm_w1 selfandpure) (rcap hiinoutpartytherm_w2 loinoutpartytherm_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("All", size(large)) ytitle("In-Out Party Therms", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(45(5)65, labsize(4) angle(0))

*DEMOCRATS
clear 
use polbeh_partsocid_dataverse.dta

collapse (mean) meaninoutpartytherm_dems_w1=inoutpartytherm (sd) sdinoutpartytherm_dems_w1=inoutpartytherm (count) n_w1=inoutpartytherm if wave==1 & democrat==1, by(selfandpure)
generate hiinoutpartytherm_dems_w1 = meaninoutpartytherm_dems_w1 + invttail(n-1,0.050)*(sdinoutpartytherm_dems_w1 / sqrt(n)) 
generate loinoutpartytherm_dems_w1 = meaninoutpartytherm_dems_w1 - invttail(n-1,0.050)*(sdinoutpartytherm_dems_w1 / sqrt(n))
generate meaninoutpartytherm_demsr_w1=round(meaninoutpartytherm_dems_w1, 0.01)
format meaninoutpartytherm_demsr_w1 %9.2f
save demsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if treatw1==1

collapse (mean) meaninoutpartytherm_dems_w2=inoutpartytherm (sd) sdinoutpartytherm_dems_w2=inoutpartytherm (count) n_w2=inoutpartytherm if wave==2 & democrat==1, by(selfandpure)
generate hiinoutpartytherm_dems_w2 = meaninoutpartytherm_dems_w2 + invttail(n-1,0.050)*(sdinoutpartytherm_dems_w2 / sqrt(n)) 
generate loinoutpartytherm_dems_w2 = meaninoutpartytherm_dems_w2 - invttail(n-1,0.050)*(sdinoutpartytherm_dems_w2 / sqrt(n))
generate meaninoutpartytherm_demsr_w2=round(meaninoutpartytherm_dems_w2, 0.01)
format meaninoutpartytherm_demsr_w2 %9.2f
save demsw2, replace

append using demsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meaninoutpartytherm_demsr_w1 selfandpure) (bar meaninoutpartytherm_demsr_w2 selfandpure) (rcap hiinoutpartytherm_dems_w1 loinoutpartytherm_dems_w1 selfandpure) (rcap hiinoutpartytherm_dems_w2 loinoutpartytherm_dems_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Democrats", size(large)) ytitle("In-Out Party Therms", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(45(5)65, labsize(4) angle(0))


*REPUBLICANS
clear 
use polbeh_partsocid_dataverse.dta

collapse (mean) meaninoutpartytherm_reps_w1=inoutpartytherm (sd) sdinoutpartytherm_reps_w1=inoutpartytherm (count) n_w1=inoutpartytherm if wave==1 & republican==1, by(selfandpure)
generate hiinoutpartytherm_reps_w1 = meaninoutpartytherm_reps_w1 + invttail(n-1,0.050)*(sdinoutpartytherm_reps_w1 / sqrt(n)) 
generate loinoutpartytherm_reps_w1 = meaninoutpartytherm_reps_w1 - invttail(n-1,0.050)*(sdinoutpartytherm_reps_w1 / sqrt(n))
generate meaninoutpartytherm_repsr_w1=round(meaninoutpartytherm_reps_w1, 0.01)
format meaninoutpartytherm_repsr_w1 %9.2f
save repsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if treatw1==1

collapse (mean) meaninoutpartytherm_reps_w2=inoutpartytherm (sd) sdinoutpartytherm_reps_w2=inoutpartytherm (count) n_w2=inoutpartytherm if wave==2 & republican==1, by(selfandpure)
generate hiinoutpartytherm_reps_w2 = meaninoutpartytherm_reps_w2 + invttail(n-1,0.050)*(sdinoutpartytherm_reps_w2 / sqrt(n)) 
generate loinoutpartytherm_reps_w2 = meaninoutpartytherm_reps_w2 - invttail(n-1,0.050)*(sdinoutpartytherm_reps_w2 / sqrt(n))
generate meaninoutpartytherm_repsr_w2=round(meaninoutpartytherm_reps_w2, 0.01)
format meaninoutpartytherm_repsr_w2 %9.2f
save repsw2, replace

append using repsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar meaninoutpartytherm_repsr_w1 selfandpure) (bar meaninoutpartytherm_repsr_w2 selfandpure) (rcap hiinoutpartytherm_reps_w1 loinoutpartytherm_reps_w1 selfandpure) (rcap hiinoutpartytherm_reps_w2 loinoutpartytherm_reps_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Republicans", size(large)) ytitle("In-Out Party Therms.", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(45(5)65, labsize(4) angle(0))


*** SA Treat in Wave 1 vs Wave 2 (all subjects) -- Traits
*ALL

clear
use polbeh_partsocid_dataverse.dta

collapse (mean) minoutpartytraitsindex_w1=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_w1=inoutpartytraitsindex (count) n_w1=inoutpartytraitsindex if wave==1 , by(selfandpure)
generate hiinoutpartytraitsindex_w1 = minoutpartytraitsindex_w1 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_w1 / sqrt(n)) 
generate loinoutpartytraitsindex_w1 = minoutpartytraitsindex_w1 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_w1 / sqrt(n))
generate minoutpartytraitsindexr_w1=round(minoutpartytraitsindex_w1, 0.01)
format minoutpartytraitsindexr_w1 %9.2f
save allw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if treatw1==1

collapse (mean) minoutpartytraitsindex_w2=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_w2=inoutpartytraitsindex (count) n_w2=inoutpartytraitsindex if wave==2 , by(selfandpure)
generate hiinoutpartytraitsindex_w2 = minoutpartytraitsindex_w2 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_w2 / sqrt(n)) 
generate loinoutpartytraitsindex_w2 = minoutpartytraitsindex_w2 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_w2 / sqrt(n))
generate minoutpartytraitsindexr_w2=round(minoutpartytraitsindex_w2, 0.01)
format minoutpartytraitsindexr_w2 %9.2f
save allw2, replace


append using allw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar minoutpartytraitsindexr_w1 selfandpure) (bar minoutpartytraitsindexr_w2 selfandpure) (rcap hiinoutpartytraitsindex_w1 loinoutpartytraitsindex_w1 selfandpure) (rcap hiinoutpartytraitsindex_w2 loinoutpartytraitsindex_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("All", size(large)) ytitle("In-Out Party Supp. Traits", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(3(.2)5.5, labsize(4) angle(0))

*DEMOCRATS

clear
use polbeh_partsocid_dataverse.dta

collapse (mean) minoutpartytraitsindex_dems_w1=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_dems_w1=inoutpartytraitsindex (count) n_w1=inoutpartytraitsindex if wave==1 & democrat==1, by(selfandpure)
generate hiinoutpartytraitsindex_dems_w1 = minoutpartytraitsindex_dems_w1 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_dems_w1 / sqrt(n)) 
generate loinoutpartytraitsindex_dems_w1 = minoutpartytraitsindex_dems_w1 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_dems_w1 / sqrt(n))
generate minoutpartytraitsindex_demsr_w1=round(minoutpartytraitsindex_dems_w1, 0.01)
format minoutpartytraitsindex_demsr_w1 %9.2f
save demsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if treatw1==1

collapse (mean) minoutpartytraitsindex_dems_w2=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_dems_w2=inoutpartytraitsindex (count) n_w2=inoutpartytraitsindex if wave==2 & democrat==1, by(selfandpure)
generate hiinoutpartytraitsindex_dems_w2 = minoutpartytraitsindex_dems_w2 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_dems_w2 / sqrt(n)) 
generate loinoutpartytraitsindex_dems_w2 = minoutpartytraitsindex_dems_w2 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_dems_w2 / sqrt(n))
generate minoutpartytraitsindex_demsr_w2=round(minoutpartytraitsindex_dems_w2, 0.01)
format minoutpartytraitsindex_demsr_w2 %9.2f
save demsw2, replace


append using demsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar minoutpartytraitsindex_demsr_w1 selfandpure) (bar minoutpartytraitsindex_demsr_w2 selfandpure) (rcap hiinoutpartytraitsindex_dems_w1 loinoutpartytraitsindex_dems_w1 selfandpure) (rcap hiinoutpartytraitsindex_dems_w2 loinoutpartytraitsindex_dems_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Democrats", size(large)) ytitle("In-Out Party Supp. Traits", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(3(.2)5.5, labsize(4) angle(0))


*REPUBLICANS
clear
use polbeh_partsocid_dataverse.dta


collapse (mean) minoutpartytraitsindex_reps_w1=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_reps_w1=inoutpartytraitsindex (count) n_w1=inoutpartytraitsindex if wave==1 & republican==1, by(selfandpure)
generate hiinoutpartytraitsindex_reps_w1 = minoutpartytraitsindex_reps_w1 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_reps_w1 / sqrt(n)) 
generate loinoutpartytraitsindex_reps_w1 = minoutpartytraitsindex_reps_w1 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_reps_w1 / sqrt(n))
generate minoutpartytraitsindex_repsr_w1=round(minoutpartytraitsindex_reps_w1, 0.01)
format minoutpartytraitsindex_repsr_w1 %9.2f
save repsw1, replace

clear
use polbeh_partsocid_dataverse.dta
drop if treatw1==1

collapse (mean) minoutpartytraitsindex_reps_w2=inoutpartytraitsindex (sd) sdinoutpartytraitsindex_reps_w2=inoutpartytraitsindex (count) n_w2=inoutpartytraitsindex if wave==2 & republican==1, by(selfandpure)
generate hiinoutpartytraitsindex_reps_w2 = minoutpartytraitsindex_reps_w2 + invttail(n-1,0.050)*(sdinoutpartytraitsindex_reps_w2 / sqrt(n)) 
generate loinoutpartytraitsindex_reps_w2 = minoutpartytraitsindex_reps_w2 - invttail(n-1,0.050)*(sdinoutpartytraitsindex_reps_w2 / sqrt(n))
generate minoutpartytraitsindex_repsr_w2=round(minoutpartytraitsindex_reps_w2, 0.01)
format minoutpartytraitsindex_repsr_w2 %9.2f
save repsw2, replace

append using repsw1
replace selfandpure=2 if n_w2!=. & selfandpure==0
replace selfandpure=3 if n_w2!=. & selfandpure==1

graph twoway (bar minoutpartytraitsindex_repsr_w1 selfandpure) (bar minoutpartytraitsindex_repsr_w2 selfandpure) (rcap hiinoutpartytraitsindex_reps_w1 loinoutpartytraitsindex_reps_w1 selfandpure) (rcap hiinoutpartytraitsindex_reps_w2 loinoutpartytraitsindex_reps_w2 selfandpure),   xscale(range(-0.25 1.25)) legend(off) xlabel(0 "W1 SA Control" 1 "W1 SA Treat." 2 "W2 SA Control" 3 "W2 SA Treat.", noticks)  xtitle("Republicans", size(large)) ytitle("In-Out Party Supp. Traits", size(large)) graphregion(color(white)) bgcolor(white) scheme(s2mono) ylab(3(.2)5.5, labsize(4) angle(0))
